<template>
  <div class="img-content">
    <eagle-image :src="certImg" />
    <div class="tac mt-10 mb-10">
      <eagle-button type="info" @click="downloadCertImage">下载</eagle-button>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      baseUrl: process.env.VUE_APP_BASE_API,
      imgUrl: this.$route.query.imgUrl,
      loading: false,
      certImg: "",
      data: {},
    };
  },
  created() {
    var temp_baseUrl = this.baseUrl;
    var temp_imgUrl = this.imgUrl;
    this.certImg = temp_baseUrl + temp_imgUrl;
  },
  methods: {
    downloadCertImage() {
    var x = new XMLHttpRequest();
    x.open("GET",this.certImg, true);
    x.responseType = 'blob';
    x.onload=function(e) {
        var url = window.URL.createObjectURL(x.response)
        var a = document.createElement("a");
        a.href = url;
        a.download = "施工人员通行证"; //下载后的文件名
        a.click();
    }
    x.send();
    },
  },
};
</script>

<style lang="less" scoped>
.img-content {
  width: 100%;
}
</style>